package com.ibeeking.gmc.global.g.rest.controller.v1.feign;

import com.ibeeking.found.common.entity.open.OpenAuthDTO;
import com.ibeeking.found.common.entity.open.OpenAuthQuery;
import com.ibeeking.found.common.entity.open.SimpleOpenAuthDTO;
import com.ibeeking.gmc.global.api.common.param.OpenAuthCancelParam;
import com.ibeeking.gmc.global.api.common.param.OpenAuthModifyTenantIdParam;
import com.ibeeking.gmc.global.api.common.param.OpenAuthParam;
import com.ibeeking.gmc.global.g.rest.service.IOpenAuthService;
import com.ibeeking.nematos.constants.enums.OperateLogTypeEnum;
import com.ibeeking.nematos.log.annotation.Log;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import java.util.List;

/**
 * @ClassName ClientController控制器
 * @Description 授权客户端
 * @Author ibeeking
 * @Date 2021-05-18 10:34
 **/
@RestController
@RequestMapping("/g/openAuth/feign/v1")
public class OpenAuthFeignController {

    @Resource
    private IOpenAuthService openAuthServiceImpl;

    @Log(logType = OperateLogTypeEnum.MODIFY, describe = "更新开放平台授权信息")
    @PostMapping("/modifyAuth")
    public Boolean modifyAuth(@RequestBody OpenAuthParam param) {
        return openAuthServiceImpl.modifyAuth(param);
    }

    @Log(logType = OperateLogTypeEnum.DEL, describe = "取消开放平台授权信息")
    @PostMapping("/cancelAuth")
    public Boolean cancelAuth(@RequestBody OpenAuthCancelParam param) {
        return openAuthServiceImpl.cancelAuth(param);
    }

    @Log(logType = OperateLogTypeEnum.MODIFY, describe = "根据租户ID更新开放平台授权信息")
    @PostMapping("/modifyAuthTenantId")
    public Boolean modifyAuthTenantId(@RequestBody OpenAuthModifyTenantIdParam param) {
        return openAuthServiceImpl.modifyAuthTenantId(param);
    }

    @Log(logType = OperateLogTypeEnum.QUERY, describe = "取得租户的开放平台授权信息列表")
    @PostMapping("/queryOpenAuthList")
    public List<OpenAuthDTO> queryOpenAuthList(@RequestBody OpenAuthQuery query) {
        return openAuthServiceImpl.queryOpenAuthList(query);
    }

    @Log(logType = OperateLogTypeEnum.QUERY, describe = "取得租户的开放平台授权信息列表")
    @PostMapping("/querySimpleOpenAuthList")
    public List<SimpleOpenAuthDTO> querySimpleOpenAuthList(@RequestBody OpenAuthQuery query) {
        return openAuthServiceImpl.querySimpleOpenAuthList(query);
    }

    @Log(logType = OperateLogTypeEnum.QUERY, describe = "取得租户的开放平台授权信息")
    @PostMapping("/queryOpenAuthOne")
    public OpenAuthDTO queryOpenAuthOne(@RequestBody OpenAuthQuery query) {
        return openAuthServiceImpl.queryOpenAuthOne(query);
    }

    @Log(logType = OperateLogTypeEnum.QUERY, describe = "取得租户的开放平台授权信息")
    @PostMapping("/querySimpleOpenAuthOne")
    public SimpleOpenAuthDTO querySimpleOpenAuthOne(@RequestBody OpenAuthQuery query) {
        return openAuthServiceImpl.querySimpleOpenAuthOne(query);
    }

}
